package com.cman777.springc.ratelimiter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * @author chenzhicong
 * @time 2020/9/18 15:36
 */
@Slf4j
public class ReloadRulesTask {
    private RateLimiterClient rateLimiterClient;
    public ReloadRulesTask(RateLimiterClient rateLimiterClient){
        this.rateLimiterClient = rateLimiterClient;
    }
    /**
     * 1分钟执行一次
     */
    @Scheduled(cron = "0 */2 * * * ?")
    public void reloadRule(){
        log.info("重载限流规则开始");
        rateLimiterClient.reloadRules();
        log.info("重载限流规则结束");
    }

}
